﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Action = DataLayer.Model.Objects.Action;
using DataLayer.Model.Objects;

namespace Overview.Components
{
    /// <summary>
    /// Interaction logic for ActionInListComponent.xaml
    /// </summary>
    public partial class ActionInListComponent : UserControl
    {
        private Action _action;
        public Action Action { get { return _action; } }
        private Macro _macro;
        public Macro Macro { get { return _macro; } }

        private Type _type;

        public EventHandler EditMacroCall;
        public EventHandler ChangeTargetCall;

        public ActionInListComponent(Action pAction)
        {
            InitializeComponent();
            _action = pAction;
            lblActionText.Content = _action.FormSlachCommand();
            _type = typeof(Action);
        }
        public ActionInListComponent(Macro pMacro)
        {
            InitializeComponent();
            _macro = pMacro;
            lblActionText.Content = pMacro.Name;
            _type = typeof(Macro);
        }

        private void UserControl_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (_type.Equals(typeof(Macro)))
            {
                if (this.EditMacroCall != null)
                    this.EditMacroCall(Macro,null);
            }
            else
            {

            }
        }
    }
}
